package com.cy.pj.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;

/**
 * VO: 封装控制层要返回给客户端的数据
 *
 * @author zimin
 * @create 2019 -07-09 10:27
 */
@Data
@RequiredArgsConstructor
@AllArgsConstructor
public class JsonResult implements Serializable {
    private static final long serialVersionUID = 772895272626152880L;
    /**
     * state
     * 1 ok
     * 0 error
     */
    private int state=1;
    private String message = "ok";
    private Object data;

    /**
     * Instantiates a new Json result.
     *
     * @param message the message
     */
    public JsonResult(String message) {
this.message = message;
}

    /**
     * Instantiates a new Json result.
     *
     * @param data the data
     */
    public JsonResult(Object data) {
    this.data = data;
    }

    /**
     * Instantiates a new Json result.
     *
     * @param e the e
     */
    public JsonResult(Throwable e) {
        this.message = e.getMessage();
        this.state = 0;
    }
}
